<template>
    <div class="layout">
        <!-- 顶部标签 -->
        <inner-header class="head">
            <template v-slot:head-title>
                <span>全部游戏</span>
            </template>
        </inner-header>

        <!-- 主要内容 -->
        <div class="main">
            <ul>
                <li v-for="(item, index) in arr" :key="index">
                    <router-link :to="{path: '/games/detail', query: {id: index}}">
                        <div class="pic" :style="{'background-image':'url('+item.src+')', 'background-color': 'aliceblue'}"></div>
                        <span>{{item.name}}</span>
                    </router-link>
                </li>
            </ul>
        </div>

        <!-- 底部导航 -->
        <app-nav></app-nav>
    </div>
</template>

<script>
import innerHeader from '@/components/inner-header.vue'
import appNav from '@/components/app-nav.vue'
import { gameArray } from '@/assets/data/game.js'
export default ({
    name: 'games',
    components: {
        innerHeader,
        appNav
    },
    data() {
        return {
            arr: gameArray // 游戏数据
        }
    }
})
</script>


<style lang="scss" scoped>
.layout {
    width: 100%;
    background-color: #2E2E2E;
    .main {
        width: 100%;
        margin-top: 80px;
        margin-bottom: 120px;
        padding: 15px 15px 0;
        box-sizing: border-box;
        overflow: hidden;
        ul {
            width: 100%;
            display: flex;
            justify-content: flex-start;
            flex-wrap: wrap;
            overflow: hidden;
            li {
                width: 33%;
                margin-bottom: 15px;
                text-align: center;
                flex-shrink: 0;
                box-sizing: border-box;
                a {
                    width: 100%;
                    display: flex;
                    flex-direction: column;
                    align-items: center;
                    .pic {
                        width: 100px;
                        height: 150px;
                        border-radius: 5px;
                        background-repeat: no-repeat;
                        background-size: cover;
                        background-position: center;
                    }
                    span {
                        width: 100px;
                        font-size: 13px;
                        display: inline-block;
                        padding: 5px 0;
                        color: white;
                        overflow: hidden;
                        text-overflow: ellipsis;
                        white-space: nowrap;
                    }
                }
            }
        }
    }
}
</style>